/**
 * @author Juko
 */
package ganga.custodian.utils;

import ganga.custodian.R;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SpinnerAdapter extends BaseAdapter {


    private Context context;
    private List<SpinnerMenuClass> workList;
    public SpinnerAdapter(Context context, List<SpinnerMenuClass> workList) {
        this.context = context;
        this.workList = workList;
    }

   public int getCount() {
    return workList.size();
   }

    public Object getItem(int position) {
        return workList.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup viewGroup) {
        SpinnerMenuClass entry = workList.get(position);
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.adapterforspinner, null);
        }
        TextView text1 = (TextView) convertView.findViewById(R.id.spAdText1);
        text1.setText(entry.getFirstText());

        TextView text2 = (TextView) convertView.findViewById(R.id.spAdText2);
        text2.setText(entry.getSecondText());
        

        return convertView;
    }


}
